package com.chanzany.factory;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.Reader;

public class Main {
    public static void main(String[] args) {
//        Calendar calendar = Calendar.getInstance();
//        System.out.println("年："+calendar.get(Calendar.YEAR));
//        System.out.println("月："+calendar.get(Calendar.MONTH)+1);
//        System.out.println("月："+calendar.get(Calendar.DAY_OF_MONTH));
        try {
            // 基本mybatis环境
            // 1.定义mybatis_config文件地址
            String resources = "mybatis_config.xml";
            // 2.获取InputStreamReaderIo流
            Reader reader = Resources.getResourceAsReader(resources);
            // 3.获取SqlSessionFactory
            SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
            // 4.获取Session
            SqlSession sqlSession = sqlSessionFactory.openSession();
            // 5.操作Mapper接口
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
